# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=ytdl-sub
pkgver=2024.04.28
pkgrel=0
pkgdesc="tool for downloading media with yt-dlp and creating metadata"
url="https://github.com/jmbannon/ytdl-sub"
arch="noarch"
license="GPL-3.0-only"
depends="
	ffmpeg
	py3-colorama
	py3-mediafile
	py3-mergedeep
	py3-yaml
	yt-dlp-core
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="py3-pytest py3-pytest-cov"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://codeload.github.com/jmbannon/ytdl-sub/tar.gz/refs/tags/$pkgver"
# tests connect out to the internet
options="!check"

prepare() {
	default_prepare

	# hardcoded incorrect version
	cat >>src/ytdl_sub/__init__.py <<-EOF
	__pypi_version__ = "$pkgver"
	__local_version__ = "$pkgver"
	EOF
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
dc8037804b5d0fb37f7caef7f14d763159dc7a34e2cc088a4c03b4a72682ed4aaa493012184bac502f04200e263f3c534e2e7666f72a870f7fa8068ca921ea48  ytdl-sub-2024.04.28.tar.gz
"
